package javacode.chapter07.keyword_this;

public class TestPerson{
    public static void main(String[] args) {
        Person p1 = new Person();
        Person p2 = new Person();

        p1.name = "jackie";
        p1.age = 18;
        p2.name = "RockStone";
        p2.age = 20;

        System.out.println("p1是否等于p2：" + p1.compareTo(p2));
    }
}



class Person{
    String name;
    int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    Boolean compareTo(Person p){
        if (this.name.equals(p.name) && this.age == p.age){
            return true;
        }else{
            return false;
        }
    }
}